package com.ymx.quanjuhe.dao;

import com.ymx.quanjuhe.bean.VisitLog;
import com.ymx.quanjuhe.bean.VisitLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Component;

@Component
public interface VisitLogMapper {
    @SelectProvider(type=VisitLogSqlProvider.class, method="countByExample")
    long countByExample(VisitLogExample example);

    @DeleteProvider(type=VisitLogSqlProvider.class, method="deleteByExample")
    int deleteByExample(VisitLogExample example);

    @Delete({
        "delete from tl_visit_log",
        "where visit_id = #{visitId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer visitId);

    @Insert({
        "insert into tl_visit_log (visit_id, visit_ip, ",
        "visit_time, visit_address, ",
        "visit_browser)",
        "values (#{visitId,jdbcType=INTEGER}, #{visitIp,jdbcType=VARCHAR}, ",
        "#{visitTime,jdbcType=TIMESTAMP}, #{visitAddress,jdbcType=VARCHAR}, ",
        "#{visitBrowser,jdbcType=VARCHAR})"
    })
    int insert(VisitLog record);

    @InsertProvider(type=VisitLogSqlProvider.class, method="insertSelective")
    int insertSelective(VisitLog record);

    @SelectProvider(type=VisitLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="visit_id", property="visitId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="visit_ip", property="visitIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="visit_time", property="visitTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="visit_address", property="visitAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="visit_browser", property="visitBrowser", jdbcType=JdbcType.VARCHAR)
    })
    List<VisitLog> selectByExample(VisitLogExample example);

    @Select({
        "select",
        "visit_id, visit_ip, visit_time, visit_address, visit_browser",
        "from tl_visit_log",
        "where visit_id = #{visitId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="visit_id", property="visitId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="visit_ip", property="visitIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="visit_time", property="visitTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="visit_address", property="visitAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="visit_browser", property="visitBrowser", jdbcType=JdbcType.VARCHAR)
    })
    VisitLog selectByPrimaryKey(Integer visitId);

    @UpdateProvider(type=VisitLogSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") VisitLog record, @Param("example") VisitLogExample example);

    @UpdateProvider(type=VisitLogSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") VisitLog record, @Param("example") VisitLogExample example);

    @UpdateProvider(type=VisitLogSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(VisitLog record);

    @Update({
        "update tl_visit_log",
        "set visit_ip = #{visitIp,jdbcType=VARCHAR},",
          "visit_time = #{visitTime,jdbcType=TIMESTAMP},",
          "visit_address = #{visitAddress,jdbcType=VARCHAR},",
          "visit_browser = #{visitBrowser,jdbcType=VARCHAR}",
        "where visit_id = #{visitId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(VisitLog record);
}